package com.nbufe.controller;

import com.nbufe.domain.ResponseResult;
import com.nbufe.domain.dto.factor.AddFactorDto;
import com.nbufe.domain.dto.factor.EditFactorDto;
import com.nbufe.domain.entity.EmissionOrigin;
import com.nbufe.domain.vo.factor.QueryFactorDto;
import com.nbufe.service.EmissionFactorBankService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 碳排放因子库Controller
 *
 * @Author luzhiheng
 * @Date 2023/12/27 10:18
 */
@CrossOrigin
@RestController
@RequestMapping("/emission_factor")
public class EmissionFactorController {

    @Resource
    private EmissionFactorBankService emissionFactorBankService;

    @GetMapping("/queryAllMaterial")
    public ResponseResult queryAllMaterial() {
        return emissionFactorBankService.queryAllMaterial();
    }

    @PostMapping("/pageList")
    public ResponseResult pageList(@RequestBody QueryFactorDto dto) {
        return emissionFactorBankService.pageList(dto);
    }

    @DeleteMapping("/deleteFactor/{id}")
    public ResponseResult deleteFactor(@PathVariable Long id) {
        return emissionFactorBankService.deleteFactorById(id);
    }

    @DeleteMapping("/deleteBatchFactor")
    public ResponseResult deleteBatchFactor(@RequestBody List<Long> ids) {
        return emissionFactorBankService.deleteBatchFactor(ids);
    }

    @GetMapping("/queryDetail/{id}")
    public ResponseResult queryDetail(@PathVariable Long id) {
        return emissionFactorBankService.queryDetail(id);
    }

    @PutMapping("/addFactor")
    public ResponseResult addFactor(@RequestBody AddFactorDto dto) {
        return emissionFactorBankService.addFactor(dto);
    }

    @PutMapping("/editFactor")
    public ResponseResult editFactor(@RequestBody EditFactorDto dto) {
        return emissionFactorBankService.editFactor(dto);
    }

    @GetMapping("/queryFactor/{id}")
    public ResponseResult queryFactor(@PathVariable Long id) {
        return emissionFactorBankService.queryFactory(id);
    }
}
